package org.shoukaiseki.supersaiyan.common.core.domain.base;

import java.io.Serializable;
import java.util.*;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Entity基类
 *
 * @author ruoyi
 */
public class BaseEntity implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 搜索值 */
    private String searchValue;

    /** 创建者 */
    private Long createUserId;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 更新者 */
    private Long updateUserId;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /** 备注 */
    private String remark;

    /** 请求参数 */
    private Map<String, Object> params;

    /**
     * 本次update时允许空值(null)的属性集合
     */
    private List<String> mybatisAllowNullPropNameList;

    public String getSearchValue()
    {
        return searchValue;
    }

    public void setSearchValue(String searchValue)
    {
        this.searchValue = searchValue;
    }

    public Long getCreateUserId()
    {
        return createUserId;
    }

    public void setCreateUserId(Long createUserId)
    {
        this.createUserId = createUserId;
    }

    public Date getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(Date createTime)
    {
        this.createTime = createTime;
    }

    public Long getUpdateUserId()
    {
        return updateUserId;
    }

    public void setUpdateUserId(Long updateUserId)
    {
        this.updateUserId = updateUserId;
    }

    public Date getUpdateTime()
    {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime)
    {
        this.updateTime = updateTime;
    }

    public String getRemark()
    {
        return remark;
    }

    public void setRemark(String remark)
    {
        this.remark = remark;
    }

    public Map<String, Object> getParams()
    {
        if (params == null)
        {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params)
    {
        this.params = params;
    }

    @JsonIgnore
    @JsonProperty
    @JSONField(serialize = false)
    public List<String> getMybatisAllowNullPropNameList() {
        if(mybatisAllowNullPropNameList==null){
            mybatisAllowNullPropNameList=new ArrayList<>();
        }
        return mybatisAllowNullPropNameList;
    }


    /**
     * 本次update时可以设置null值的字段
     * @param propNames
     * {@code
    //例如,这些值更新时可以为null,一般在 Controller 定义,单独的修改接口,只设置页面上显示的字段可以为null值
    sysBusinessActivty.addMybatisAllowNullPropNameList("baLabel","bcId","baScale","remark","applBeginday","applEndLastday","beginday","lastday","baSuperiorId");
    }
     */
    public void addMybatisAllowNullPropNameList(String... propNames){
        List<String> mybatisAllowNullPropNameList = getMybatisAllowNullPropNameList();
        if (propNames!=null) {
            for (String propName : propNames) {
                mybatisAllowNullPropNameList.add(propName);
            }
        }
    }

}
